#include <iostream>
using namespace std;

#include "MenuH.h"
#include "gotoxyH.h"

void Menu::displayOptions()
{
	for ( unsigned int i=0; i < m_num_of_options; i++)
		cout << i+1 << "> " << m_options_text[ i] << endl;
	cout << "Please enter your choice:";
}


void Menu::Init( unsigned int num_of_options)
{
	m_num_of_options = num_of_options;
	m_options_text = new string [num_of_options];
}


void Menu::Destruct( )
{

	delete []m_options_text;
}


void Menu::set( unsigned int option_number, const string &option_text)
{
	m_options_text[ option_number ] = option_text;
}


unsigned int Menu::choose( )
{
	unsigned int l_choice = m_num_of_options;

	clrscr();
	displayOptions();
	cin >> l_choice;
	while ( l_choice > m_num_of_options || l_choice<=0 )
	{
		cerr << "Wrong option ! Please choose an option between 1 2 3 4 and 9" 
			 << m_num_of_options << endl << endl << endl;
		displayOptions();
		cin >> l_choice; 
	}
	return l_choice;
}
